import 'package:flutter/material.dart';
import 'package:get/get.dart';

class CustomConfirmDialogWidget extends StatelessWidget {
  ///标题
  final String? title;

  ///描述
  final String? label;

  ///确认按钮文字
  final String? confirmText;

  ///取消按钮文字
  final String? cancelText;

  ///确认事件
  final VoidCallback? onConfirm;

  ///取消事件
  final VoidCallback? onCancel;

  ///是否允许取消
  final bool isCancel;
  const CustomConfirmDialogWidget({
    super.key,
    this.title,
    this.label,
    this.confirmText,
    this.isCancel = true,
    this.cancelText,
    required this.onConfirm,
    this.onCancel,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      constraints: BoxConstraints(minHeight: 130.0),
      width: Get.width * 0.8,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(5.0),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Padding(
            padding: EdgeInsets.all(10.0),
            child: Text(
              title ?? '提示',
              style: TextStyle(
                fontSize: 17.0,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.symmetric(vertical: 10.0),
            child: Text(
              label ?? '确定要执行此操作?',
              style: TextStyle(
                fontSize: 15.0,
                color: Color(0xFF606266),
              ),
            ),
          ),
          Divider(height: 1),
          Row(
            children: [
              Expanded(
                child: SizedBox(
                  height: 50.0,
                  child: TextButton(
                    onPressed: onCancel,
                    child: Text(cancelText ?? '取消'),
                  ),
                ),
              ),
              SizedBox(height: 50, child: VerticalDivider(width: 1)),
              Expanded(
                child: SizedBox(
                  height: 50.0,
                  child: TextButton(
                    onPressed: onConfirm,
                    child: Text(confirmText ?? '确定'),
                  ),
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
}
